<%-- 
    Document   : ViewCart
    Created on : Sep 27, 2011, 1:51:50 PM
    Author     : James
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.util.List, java.util.ArrayList, servlet.Cart, BusinessLogic.Constants, EntityState.ItemDetailsState, EntityState.ReservationState, EntityState.ItemState, EntityState.VoucherState, EntityState.ReservableUnitState, org.joda.time.DateTime, org.joda.time.DateTimeZone"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Shopping Cart</title>
        <link rel="stylesheet" href="../customer/main_style_sheet.css" />
        <script type="text/javascript" src="../customer/script/Utilities.js"></script>
        <script type='text/javascript' src='../jQuery/jquery-1.6.1.min.js'></script>

        <!-- InstanceEndEditable -->
        <script language="javascript" type="text/javascript" src="../TransactWeb/js/jquery-1.6.4.min.js"></script>
        <script type="text/javascript" src="../TransactWeb/js/fieldsetCollapse.js"></script>
        <script type="text/javascript" src="../TransactWeb/js/tcubmenu.js"></script>
        <script type="text/javascript" src="../TransactWeb/js/accordion.js"></script>
        <script type="text/javascript" src="../TransactWeb/js/scroller.js"></script>
        <link rel="stylesheet" type="text/css" href="../TransactWeb/css/tcubaccd.css" />
        <link rel="stylesheet" type="text/css" href="../TransactWeb/css/promotion.css" />
        <link rel="stylesheet" type="text/css" href="../TransactWeb/css/templatestyle.css" />
        <link rel="stylesheet" type="text/css" href="../TransactWeb/css/tcubeadmin.css" />
        <link rel="stylesheet" type="text/css" href="../TransactWeb/css/gridsys.css" />
        <link rel="stylesheet" type="text/css" href="../TransactWeb/css/reset1.css" />
        <link rel="stylesheet" type="text/css" href="../TransactWeb/css/cm.css" />
        <!-- InstanceBeginEditable name="head" -->
        <!-- InstanceEndEditable -->
        <link href="../TransactWeb/css/gridsys.css" rel="stylesheet" type="text/css" />
        <link href="../TransactWeb/css/templatestyle.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript">
            <!--
            window.onload = showPage('Login', 'login_panel');
            //-->
        </script>
    </head>

    <body>
        <!-- InstanceBeginRepeat name="Header" --><!-- InstanceBeginRepeatEntry -->
        <div id="header_bg">
            <div class="container_12" id="lang_bar">
                <div class="grid_6 push_5" id="lang">
                    <table width="480" border="0">
                        <tr>
                            <td width="30">Register</td>
                            <td width="50">Contact Us</td>
                            <td width="40">SiteMap</td>
                            <td width="200"> Language  :  English | Bahasa Indonesia | 简体中文 </td>

                        </tr>
                    </table>
                </div>
            </div>

            <div class="container_12"> 
                <div class="grid_3 push_3 header_menu">About.</div>
                <div class="grid_2 push_2 header_menu">Browse.</div>
                <div class="grid_2 push_2 header_menu" id="plan">Plan.</div>
                <div class="grid_3 push_2 header_menu">Socialize.</div>
                <div class="clear"></div>

                <div class="grid_1 push_3" id="header_sbabout">FoodSage<br />Singapore</div>
                <div class="grid_2 push_3" id="header_sbbrowse">Restaurant List <br />
                    Places of Attraction</div>
                <div class="grid_2 push_2" id="header_sbplan">Your Itinerary</div>
                <div class="grid_2 push_1" id="header_sbsocial">mySage &nbsp; &nbsp;Classified<br /> Mobile Application</div>
                <div class="clear"></div>
                <div class="grid_2 push_10 test" id="cart"><img src="../TransactWeb/img/template/cart.png" width="18" height="15" alt="cart" />
                    Cart 2
                </div>
            </div>
        </div>

        <div id="login">
            <div class="container_12">
                <div class="grid_4" id="welcome"> Welcome User!</div>
            </div>
        </div> 

        <!-- InstanceEndRepeatEntry --><!-- InstanceEndRepeat -->
        <!-- InstanceBeginEditable name="Content" -->
        <div class="container_12">
            <div class="grid_4 restdesc">
                <ul id="accordion">
                    <li>

                        <span class="itplan"><img src="../TransactWeb/img/cm/airplane.png" width="50" height="50" alt="travel" /> &nbsp;Itinerary Planner<br /><br />
                            <span style="font-size:12px;"> Singapore, September 2011<br />
                                September 20 - September 22</span>
                        </span>

                    </li>
                    <li>
                        <a class="heading">Day 1 - 20 September</a>
                        <ul>
                            <li><a href="#"><b>Shangri-La The Line</b><br />Category : Buffet<br /> Type : F&amp;B    </a><br /> 
                                <a href="IOTR_reservation.html" class="reserve">Make Reservation Now</a></li>
                            <li><a href="#"><b>Chuan Yang Ji Mutton Soup Steamboat</b><br />Category : Steamboat<br /> Type : F&amp;B    </a><br /> <a href="#" class="reserve">Make Reservation Now</a></li>
                            <li><a href="#"><b>Wild Olives</b><br />Category : Italian<br /> Type : F&amp;B   </a><br /> <a href="#" class="reserve">Make Reservation Now</a></li>
                        </ul>
                    </li>
                    <li>
                        <a class="heading">Day 2 - 21 September</a>
                        <ul>
                            <li><a href="#"><b>Betel Box Living Bistro</b><br />Category : Fusion <br /> Type : F&amp;B   </a><br /> 
                                <a href="#" class="reserve">Make Reservation Now</a></li>
                            <li><a href="#"><b>Ocean Kingdom Live Seafood Restaurant</b><br />Category : Seafood<br /> Type : F&amp;B    </a><br /> 
                                <a href="#" class="reserve">Make Reservation Now</a></li>

                        </ul>
                    </li>
                    <li>
                        <a class="heading">Day 3 - 22 September</a>
                        <ul>
                            <li><a href="#"><b>The Mexican Taco Bar</b><br />Category : Latin America<br /> Type : F&amp;B    </a><br /> <a href="#" class="reserve">Make Reservation Now</a></li>
                            <li><a href="#"><b>The Ballet Season</b><br />Category : Performance<br /> Type : Ticketing   </a><br /> 
                                <a href="#" class="ticket">Buy Tickets Now</a></li>
                            <li><a href="#"><b>Elton John &amp; Band Greatest Hits Tour</b><br />
                                    Category : Concert<br /> 
                                    Type : Ticketing</a><br /> <a href="#" class="ticket">Buy Tickets Now</a></li>
                        </ul>
                    </li>
                </ul>
            </div>

            <div class="reservationline">
                <div class="grid_6 reservationtype"><img src="../TransactWeb/img/template/cart.png" width="29" height="22" alt="cart" />
                    Shopping Cart
                </div>
            </div>



            <%
                // Get the cart or create a new one if the customer doesn't have one
                session = request.getSession();
                Cart cart = (Cart) session.getAttribute("cart");
                if (cart == null) {
                    cart = new Cart();
                    session.setAttribute("cart", cart);
                }
            %>
            <p style="color:purple;font-size:15px">Your reservations</p>
            <hr><br/>    
            <table>
                <tr>
                    <td>Outlet</td>
                    <td>Unit name</td>
                    <td>Start</td>
                    <td>End</td>
                    <td>No. of People</td>
                    <td>Customer's name</td>
                    <td>Contact no.</td>
                    <td>Food vouchers</td>
                    <td>No-show fee</td>
                    <td></td>
                    <td></td>
                </tr>
                <%
                    // Get list of Reservations
                    List<Cart.CartItem> listOfCartItems = cart.getListOfCartItems();
                    for (Cart.CartItem item : listOfCartItems) {
                        if (item.theReservation != null) {
                            ReservationState rs = item.theReservation;
                            ReservableUnitState reservedUnit = rs.getReservedUnit();
                %>
                <tr>
                    <td><%= reservedUnit.getOutlet().getName()%></td>
                    <td><%= reservedUnit.getReservedItem().getName()%></td>
                    <td><%= new DateTime(rs.getStartTime(), DateTimeZone.forID(reservedUnit.getOutlet().getTimezone())).toString("MMMM dd, yyyy HH:mm")%></td>
                    <td><%= new DateTime(rs.getStartTime(), DateTimeZone.forID(reservedUnit.getOutlet().getTimezone())).toString("MMMM dd, yyyy HH:mm")%></td>
                    <td><%= rs.getNumOfPeople()%></td>
                    <td><%= rs.getCustomerName()%></td>
                    <td><%= "(+" + rs.getCountryCode() + ") " + rs.getPhone()%></td>
                    <td>
                        <%
                            for (VoucherState vs : rs.getListOfVouchers()) {
                                System.out.println(vs.getId());
                            }
                        %>
                    </td>
                    <td><%= reservedUnit.getLatestReservableUnitDetails().getReservationNoShowFee()%></td>
                    <td><button type="button">Update</button></td>
                    <td><button type="button">Cancel</button></td>
                </tr>
                <%
                        }
                    }
                %>
            </table>
            <p style="color:purple;font-size:15px">Your items</p>
            <hr><br/>    
            <table>
                <tr>
                    <td>Name</td>
                    <td>Price</td>
                    <td>Discount</td>
                    <td>Additional Loyalty points</td>
                    <td>Quantity</td>
                    <td></td>
                    <td></td>
                </tr>
                <%
                    // Get list of Items
                    int i = 0;
                    for (Cart.CartItem item : listOfCartItems) {
                        i++;
                        if (item.theItem != null) {
                            ItemState is = item.theItem;
                            ItemDetailsState ids = is.getLatestItemDetails();
                %>
                <tr>
                    <td><%= is.getName()%></td>
                    <td><%= "$" + ids.getPrice() / 100 + "." + ids.getPrice() % 100%></td>
                    <td>
                        <%
                            int discount = ids.getDiscount();
                            if (discount < 0) {
                                discount = ids.getPrice() * (discount * -1) / 100;
                            }
                            System.out.print("$" + discount);
                        %>
                    </td>
                    <td><%= ids.getAdditionalLoyaltyPoint()%></td>
                    <td>
                        <input type="hidden" value="<%= Constants.CART_UPDATE_ITEM_QUANTITY%>" name="<%= "action" + i%>" />
                        <input type="hidden" value="<%= item.id%>" name="<%= "itemID" + i%>" />
                        <input type="text" value="<%= item.quantity%>" name="<%= "quantity" + i%>" />
                    </td>
                    <td><button type="submit" value="Update" onclick="update(<%= i%>)">Update</button></td>
                    <td>
                        <input type="hidden" value="<%= Constants.CART_DELETE_CART_ITEM%>" name="<%= "action" + i%>" />
                        <input type="hidden" value="<%= item.id%>" name="<%= "itemID" + i%>" />
                    </td>
                    <td><button type="submit" value="Drop" onclick="update(<%= i%>)">Drop/button></td>
                </tr>
                <%
                        }
                    }
                %>
            </table>
        </div>
        <div class="clear"></div>
    </div>

    <!-- InstanceEndEditable -->
    <!-- InstanceBeginRepeat name="Footer" --><!-- InstanceBeginRepeatEntry -->
    <div id="footer_bar">
        <div class="container_12">
            <div class="grid_12" id="footer">&copy; &nbsp;Copyright FoodSage</div>
        </div>
    </div>
    <!-- InstanceEndRepeatEntry --><!-- InstanceEndRepeat -->
</body>
<!-- InstanceEnd -->
</html>


